package com.zhengping.zpys.security.category;

import com.zhengping.zpys.base.AjaxResult;
import com.zhengping.zpys.security.role.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author chenweizuan
 * @description This is description of class
 * @version 1.0
 * @date 2020/3/31 16:11
 */
@RestController
@RequestMapping("/monitor/category")
public class CategoryController {

    @Autowired
    CategoryService categoryService;

    @PostMapping("/createCategory")
    public AjaxResult createCategory(@RequestBody(required = false) Category category){
        Integer row = categoryService.createCategory(category);
        return AjaxResult.success(row);
    }

    @PostMapping("/updateCategory")
    public AjaxResult updateCategory(@RequestBody(required = false) Category category){
        Integer row = categoryService.updateCategory(category);
        return AjaxResult.success(row);
    }

    @GetMapping("/queryCategoryList")
    public AjaxResult queryCategoryList(){
        List<Category> category = categoryService.queryCategoryList();
        return AjaxResult.success(category);
    }

    @PostMapping("/deleteCategory")
    public AjaxResult deleteCategory(@RequestBody(required = false) Long[] categoryIds){
        Integer row = categoryService.deleteCategory(categoryIds);
        return AjaxResult.success(row);
    }
}
